import type { Active } from "@/types/Active";
import type { BKResponse } from "@/types/Response";
import type { LoginSing_from, pwdss, User,youxiang,email, MessageBoard } from "@/types/User";
import BkRequestManager from "@/utils/BKRequestManage";

export class UserAPI{
    //登录函数
    static BkLogin(login_from:LoginSing_from){
      return BkRequestManager.instance.request<BKResponse<Partial<User>>>({
            url:'api/user/login/',
            method: "post",
            data: login_from,
       })
    }
   //用户名是否重复
   static repeatUsername(username:string){
    return BkRequestManager.instance.request<BKResponse<any>>({
          url:`api/username/${username}/`,
        
     })
  }
    //注册函数
    static BkSign(login_from:LoginSing_from){
        return BkRequestManager.instance.request<BKResponse<Partial<User>>>({
              url:'api/user/sign/',
              method: "post",
              data: login_from,
         })
      }
  //修改密码
  static setPassword(data:pwdss){
      return BkRequestManager.instance.request({
            url:"api/setPassword/",
            data,
            method:"post"
      })
  }
  //修改用户头像
  static setAvatars(nid:number){
    return BkRequestManager.instance.request({
          url:`api/setAvatars/${nid}/`,
          method:"put"
    })
}
//验证邮箱
static send_email(email:email){
      return BkRequestManager.instance.request({
            url:'api/send_email/',
            data:email,
            method: "post",
      })
  }
//完善用户信息
static Binding_email(data:youxiang){
      return BkRequestManager.instance.request({
            url:'api/Binding_email/',
            data,
            method: "post",
      })
  }
//取消收藏
static Cancel_collection(data:number[]){
      return BkRequestManager.instance.request({
            url:'api/Cancel_collection/',
            data,
            method: "post",
      })
  }
//获取用户收藏列表
static collection_list(){
      return BkRequestManager.instance.request<BKResponse<Active[]>>({
            url:'api/collection_list/',
      })
  }
  //用户留言
 static Leave_message(data:MessageBoard){
      return BkRequestManager.instance.request({
            url:'api/Leave_message/',
            data,
            method: "post",
      })
  }
}
